using UnityEngine;
using System.Collections;

public class Csharpshadow : MonoBehaviour
{

		public float shadowHeight = 0.01f ;
		public float shadowOpacity = 0.6f;
		public float shadowSize = 1.0f ;
		public Transform shadowPosition ;
		private float initHeight ;
		private float currentHeight ;

	Vector3 tempPosition;

		void Start ()
		{
				initHeight = shadowPosition.transform.position.y;
		}

		void Update ()
		{
		tempPosition.x = shadowPosition.transform.position.x;
		tempPosition.z = shadowPosition.transform.position.z;
		tempPosition.y = shadowHeight;
		transform.position = tempPosition;
	
				currentHeight = shadowPosition.transform.position.y;
				float shadowRate = (initHeight / currentHeight);
	
				transform.localScale = Vector3.one * shadowSize + Vector3.one * (shadowRate * 0.2f);
		Color tempColor = renderer.material.color;
		tempColor.a = shadowOpacity + (shadowRate * 0.1f);
		renderer.material.color = tempColor; 
		}
}